<template>
    <Col>
            <Card>
                <Row>
                    <Table   :columns="contactColums" :data="dataList">
                        <template slot-scope="{ row, index }" slot="custRelation">
                            <span>{{setDictTitleByType("custRelation",row.custRelation)}}</span>
                        </template>
                        <template slot-scope="{ row, index }" slot="certType">
                            <span>{{setDictTitleByType("certType",row.certType)}}</span>
                        </template>
                    </Table>
                </Row>
            </Card>

        </Col>
</template>
<script>
    import {
        queryContactListOld
    } from "../../../../api/afs-case/infomationDetail/applyCustomerDetail";
    export default {
        name: "cust-contact",
        props: {
            value: {
                type: Boolean,
                default: false
            },
            applyNo: {
                type: [Number, String],
                default: ''
            }
        },
        data() {
            return {
                contactColums: [
                    {
                        title: "姓名",
                        key: "custName",
                        minWidth: 100,
                        align: "center"
                    },
                    {
                        title: "与申请人关系",
                        key: "custRelation",
                        minWidth: 100,
                        align: "center",
                        slot:"custRelation"
                    },
                    {
                        title: "证件类型",
                        key: "certType",
                        minWidth: 100,
                        align: "center",
                        slot:"certType"
                    },
                    {
                        title: "证件号码",
                        key: "certNo",
                        minWidth: 150,
                        align: "center"
                    },
                    {
                        title: "手机号码",
                        key: "telPhone",
                        minWidth: 100,
                        align: "center"
                    },
                    {
                        title: "公司名称",
                        key: "companyName",
                        minWidth: 100,
                        align: "center"
                    },
                    {
                        title: "月收入",
                        key: "monthlyIncome",
                        minWidth: 100,
                        align: "center"
                    },
                    {
                        title: "现居住地",
                        key: "detailAddress",
                        minWidth: 100,
                        align: "center"
                    }
                ],
                dataList: [],
                loading: false
            }
        },
        methods: {
            init() {
                this.loading = true;
                let params = {
                    applyNo: this.applyNo
                }
                queryContactListOld(params).then(res => {
                    if (res.code === "0000" && res.data) {
                        this.dataList = res.data;
                    }
                    this.loading = false;
                });

            },
            getDic(v){
                let dic = []
                switch(v) {
                    case "certType":
                        dic = this.dataDic.certType;
                        break;
                    case "custRelation":
                        dic = this.dataDic.custRelation;
                        break;
                    default:
                }
                return dic;
            },

            setDictTitleByType(v1,v2){
                let dic = {}
                if(!this.getDic(v1)) return '';
                this.getDic(v1).forEach(column => {
                    if(column.value === v2){
                        dic = column;
                    }
                });
                return dic.title;
            },

        },
        mounted() {
            this.init();
        }
    }
</script>

<style scoped>

</style>
